package com.haoyu.microservicecloudprovidercategory8001.controller;

import com.haoyu.microservicecloudapi.entity.Entry;
import com.haoyu.microservicecloudprovidercategory8001.service.EntryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: 蒿雨
 * @create: 2022-04-14 8:54
 * @description:
 */
@RestController
public class EntryController {

    @Resource
    private EntryService entryService;

    @GetMapping("/entry")
    public List<Entry> list() {
        return entryService.list();

    }

    @GetMapping("/{id}/entry")
    public Entry get(@PathVariable Integer id) {
        return entryService.getById(id);

    }

    @PutMapping("/entry")
    public boolean update(@RequestBody Entry entry) {
        return entryService.updateById(entry);
    }

    @PostMapping("/entry")
    public boolean insert(@RequestBody Entry entry) {
        return entryService.save(entry);
    }

    @DeleteMapping("/entry")
    public boolean delete(@PathVariable Integer id) {
        return entryService.removeById(id);
    }

}
